package com.xiaoyy.app.extend.gateway.controller;

import com.xiaoyy.app.extend.common.vo.ZlbTicketVO;
import com.xiaoyy.app.extend.common.vo.ZlbTicketResVO;
import com.xiaoyy.app.extend.common.vo.ZlbTokenVO;
import com.xiaoyy.app.extend.common.vo.ZlbUserResVO;
import com.xiaoyy.app.extend.gateway.req.LoginWinxinReq;
import com.xiaoyy.app.extend.integration.ZlbIntegration;
import com.xiaoyy.core.common.vo.AppResponse;
import com.xiaoyy.core.common.vo.TokenVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;

import javax.servlet.http.HttpServletRequest;

/**
 * 浙里办登录
 *
 * @author chenzh
 * @date 2018-08-17
 */
@RestController
@RequestMapping(value = "/other/sso/zlb")
@Api(tags = "浙里办登录管理")
public class ZlbLoginController {
    @Autowired
    ZlbIntegration zlbIntegration;
    @PostMapping(value = "/ticketValidation", produces = "application/json;charset=UTF-8")
    @ApiOperation(value = "浙里办票据认证", notes = "浙里办票据认证")
    public AppResponse<ZlbTicketResVO> ticketValidation(@RequestBody ZlbTicketVO req) {
        return AppResponse.successData(zlbIntegration.ticketValidation(req));
    }

    @PostMapping(value = "/getUserInfo", produces = "application/json;charset=UTF-8")
    @ApiOperation(value = "根据浙里办令牌获取浙里办用户详细信息", notes = "根据令牌获取用户详细信息")
    public AppResponse<ZlbUserResVO> getUserInfo(@RequestBody ZlbTokenVO req) {
        return AppResponse.successData(zlbIntegration.getUserInfo(req));
    }

    @PostMapping(value = "/getToken", produces = "application/json;charset=UTF-8")
    @ApiOperation(value = "根据浙里办令牌获取本地token信息", notes = "根据令牌获取本地用户详细信息")
    public AppResponse<TokenVO> getToken(@RequestBody ZlbTokenVO req) {
        return zlbIntegration.getToken(req);
    }
}
